class CategoriesController < ApplicationController
  layout "application"

  def show
    @category = Category.find_by_permalink(params[:id])
    if @category.nil?
      redirect_to "/articles"
      return
    end
    @title    = @category.name if @category
    sql = "SELECT `articles`.* FROM `articles`  INNER JOIN `articles_categories` ON `articles`.id = `articles_categories`.article_id    WHERE ((`articles_categories`.category_id = #{@category.id})) order by id desc "
		@articles = Article.paginate_by_sql(sql,:per_page => 3,:page => params[:page],:order => "created_at desc")
  end

end
